<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>项目评分查询</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
    <style>
        body {
            font-family: "Microsoft YaHei", sans-serif;
            padding: 20px;
        }
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        .project-title {
            font-size: 18px;
            font-weight: bold;
        }
        .search-box {
            display: flex;
            align-items: center;
            margin-bottom: 20px;
        }
        .search-input {
            width: 300px;
            margin-right: 10px;
        }
        .table th {
            background-color: #f8f9fa;
            text-align: center;
        }
        .table td {
            text-align: center;
            vertical-align: middle;
        }
        .status-badge {
            padding: 5px 10px;
            border-radius: 20px;
            color: white;
            font-size: 12px;
        }
        .status-approved {
            background-color: #28a745;
        }
        .status-pending {
            background-color: #17a2b8;
        }
        .pagination-info {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 20px;
        }
        .supplier-panel {
            margin-top: 20px;
            border: 1px solid #dee2e6;
            border-radius: 5px;
            padding: 15px;
            background-color: #f8f9fa;
        }
        .supplier-title {
            font-weight: bold;
            margin-bottom: 15px;
        }
        .signature-area {
            margin-top: 20px;
            display: flex;
            justify-content: flex-end;
        }
        .signature-box {
            width: 150px;
            text-align: center;
        }
        .signature-line {
            border-bottom: 1px solid #000;
            margin-bottom: 5px;
            height: 40px;
        }
        .print-btn {
            margin-left: 10px;
        }
        @media print {
            .no-print {
                display: none;
            }
            .container-fluid {
                width: 100%;
            }
            .table {
                width: 100%;
            }
        }
    </style>
</head>
<body>
    <div class="container-fluid">
        <div class="header">
            <div class="project-title">项目评分查询</div>
            <div class="actions no-print">
                <button class="btn btn-primary" onclick="printPage()">
                    <i class="fa fa-print"></i> 打印
                </button>
                <button class="btn btn-success" onclick="downloadExcel()">
                    <i class="fa fa-download"></i> 导出Excel
                </button>
            </div>
        </div>

        <div class="search-box no-print">
            <input type="text" class="form-control search-input" placeholder="输入项目名称/编号/负责人">
            <button class="btn btn-primary">
                <i class="fa fa-search"></i> 搜索
            </button>
        </div>

        <div class="table-responsive">
            <table class="table table-bordered table-hover">
                <thead>
                    <tr>
                        <th width="5%">
                            <input type="checkbox" id="selectAll">
                        </th>
                        <th width="35%">项目名称</th>
                        <th width="10%">项目编号</th>
                        <th width="10%">评审日期</th>
                        <th width="10%">负责人</th>
                        <th width="10%">评审方式</th>
                        <th width="10%">评分状态</th>
                        <th width="10%">操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr data-id="1" onclick="toggleSupplierPanel(1)">
                        <td><input type="checkbox" class="row-checkbox"></td>
                        <td>福州市某医院信息化建设项目</td>
                        <td>PRJ2022-001</td>
                        <td>2022-01-14</td>
                        <td>张三</td>
                        <td>专家评审</td>
                        <td><span class="status-badge status-approved">已评审</span></td>
                        <td>
                            <button class="btn btn-sm btn-info project-detail-btn">查看详情</button>
                        </td>
                    </tr>
                    <tr data-id="2" onclick="toggleSupplierPanel(2)">
                        <td><input type="checkbox" class="row-checkbox"></td>
                        <td>某市智慧城市建设项目</td>
                        <td>PRJ2020-045</td>
                        <td>2020-09-21</td>
                        <td>李四</td>
                        <td>专家评审</td>
                        <td><span class="status-badge status-approved">已评审</span></td>
                        <td>
                            <button class="btn btn-sm btn-info project-detail-btn">查看详情</button>
                        </td>
                    </tr>
                    <tr data-id="3" onclick="toggleSupplierPanel(3)">
                        <td><input type="checkbox" class="row-checkbox"></td>
                        <td>某区智能交通系统项目</td>
                        <td>PRJ2024-012</td>
                        <td>2024-02-26</td>
                        <td>王五</td>
                        <td>专家评审</td>
                        <td><span class="status-badge status-pending">评审中</span></td>
                        <td>
                            <button class="btn btn-sm btn-info project-detail-btn">查看详情</button>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>

        <div class="pagination-info no-print">
            <div>
                共 <span id="totalPages">2</span> 页，<span id="totalItems">3</span> 条记录
            </div>
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <li class="page-item disabled">
                        <a class="page-link" href="#" aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                    <li class="page-item active"><a class="page-link" href="#">1</a></li>
                    <li class="page-item"><a class="page-link" href="#">2</a></li>
                    <li class="page-item">
                        <a class="page-link" href="#" aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                </ul>
            </nav>
        </div>

        <!-- 供应商评分面板 -->
        <div id="supplierPanel" class="supplier-panel" style="display: none;">
            <div class="supplier-title">
                项目名称：<span id="projectName">福州市某医院信息化建设项目</span>
                <div class="float-right">
                    评审日期：<span id="reviewDate">2022-01-14</span>
                </div>
            </div>
            <div class="row mb-3">
                <div class="col-md-4">
                    项目编号：<span id="projectCode">PRJ2022-001</span>
                </div>
                <div class="col-md-4">
                    项目负责人：<span id="projectManager">张三</span>
                </div>
                <div class="col-md-4">
                    联系方式：<span id="contactInfo">13800138000</span>
                </div>
            </div>

            <div class="table-responsive">
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th width="10%">序号</th>
                            <th width="20%">供应商名称</th>
                            <th width="15%">总分</th>
                            <th width="10%">排名</th>
                            <th width="15%">操作</th>
                        </tr>
                    </thead>
                    <tbody id="supplierList">
                        <tr>
                            <td>1</td>
                            <td>A公司</td>
                            <td>89</td>
                            <td>1</td>
                            <td><button class="btn btn-sm btn-info supplier-detail-btn no-print">查看详情</button></td>
                        </tr>
                        <tr>
                            <td>2</td>
                            <td>B公司</td>
                            <td>87</td>
                            <td>2</td>
                            <td><button class="btn btn-sm btn-info supplier-detail-btn no-print">查看详情</button></td>
                        </tr>
                        <tr>
                            <td>3</td>
                            <td>C公司</td>
                            <td>79</td>
                            <td>3</td>
                            <td><button class="btn btn-sm btn-info supplier-detail-btn no-print">查看详情</button></td>
                        </tr>
                        <tr>
                            <td>4</td>
                            <td>D公司</td>
                            <td>74</td>
                            <td>4</td>
                            <td><button class="btn btn-sm btn-info supplier-detail-btn no-print">查看详情</button></td>
                        </tr>
                        <tr>
                            <td>5</td>
                            <td>E公司</td>
                            <td>69</td>
                            <td>5</td>
                            <td><button class="btn btn-sm btn-info supplier-detail-btn no-print">查看详情</button></td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <div class="signature-area">
                <div class="signature-box">
                    <div class="signature-line"></div>
                    <div>专家签名</div>
                </div>
                <div class="signature-box ml-4">
                    <div class="signature-line"></div>
                    <div>日期</div>
                </div>
            </div>
        </div>
    </div>

    <!-- 供应商详情模态框 -->
    <div class="modal fade" id="supplierDetailModal" tabindex="-1" role="dialog" aria-labelledby="supplierDetailModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-xl" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="supplierDetailModalLabel">供应商评分详情</h5>
                    <div class="ml-auto mr-3">
                        <button type="button" class="btn btn-sm btn-primary no-print-modal" onclick="printModalContent()">
                            <i class="fa fa-print"></i> 打印
                        </button>
                        <button type="button" class="btn btn-sm btn-success no-print-modal" onclick="downloadDetailExcel()">
                            <i class="fa fa-download"></i> 导出Excel
                        </button>
                    </div>
                    <button type="button" class="close no-print-modal" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body" id="supplierDetailContent">
                    <div class="supplier-detail-header">
                        <div class="row">
                            <div class="col-md-6">
                                <h5>项目名称：<span id="detailProjectName">福州市某医院信息化建设项目</span></h5>
                            </div>
                            <div class="col-md-6 text-right">
                                <h5>评审日期：<span id="detailReviewDate">2022-01-14</span></h5>
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                供应商名称：<span id="detailSupplierName">A公司</span>
                            </div>
                            <div class="col-md-4">
                                总分：<span id="detailTotalScore">89</span>
                            </div>
                            <div class="col-md-4">
                                排名：<span id="detailRank">1</span>
                            </div>
                        </div>
                    </div>

                    <div class="mt-4">
                        <h5>评分明细</h5>
                        <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th width="20%">评分因素</th>
                                    <th width="20%">评分内容</th>
                                    <th width="40%">评分标准</th>
                                    <th width="20%">分值</th>
                                </tr>
                            </thead>
                            <tbody id="scoreDetailTable">
                                <tr>
                                    <td rowspan="3">报价（30分）</td>
                                    <td rowspan="3">报价（30分）</td>
                                    <td>
                                        各投标单位报价低价优先计算，即满足招标文件要求且报价最低的评标方案满分，其它各分为满分×最低投标人的价格÷该投标人的价格
                                        <br>评标得分=(基准价/报价)×30
                                    </td>
                                    <td id="priceScore">28.5</td>
                                </tr>
                                <tr>
                                    <td>
                                        对超投标报价限额过报价评定，最高限定采购预算超过限额进行价格调整后的报价，详见磋四章评标方法和评标标准>2.4及2.5。
                                    </td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>
                                        注：价格分数保留两位小数，最终得分不作为评标依据。
                                    </td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td rowspan="2">商务部分（11分）</td>
                                    <td>类似项目案例（5分）</td>
                                    <td>
                                        投标人具有近三年（2022年3月1日至本项目递交投标文件截止时间止），以签订日期为准与本项目类似业绩，每提供1份有效业绩，得1分，最多得5分。
                                        <br>注：须提供合同关键页及中标通知书复印件。【同时提供一个项目业绩的合同关键页及中标通知书复印件视为对应合同关键页及中标通知书为同一项目】
                                    </td>
                                    <td id="caseScore">4</td>
                                </tr>
                                <tr>
                                    <td>投标人资质（2分）</td>
                                    <td>
                                        投标人具备：ISO 9001质量管理体系认证证书、ISO 27001信息安全管理体系认证证书，每件投标的相关合法有效认证证明文件复印件2分。
                                    </td>
                                    <td id="qualificationScore">2</td>
                                </tr>
                                <tr>
                                    <td rowspan="2">商务部分（11分）</td>
                                    <td>知识产权（5分）</td>
                                    <td>
                                        1. 基于物联网云端的数据同步共性软件<br>
                                        2. 运维复制及本地数据归档备份软件<br>
                                        3. IP-SAN与iSCSI管理高网络覆盖软件<br>
                                        4. 云监测及交互检查软件<br>
                                        5. 智能巡检排查软件<br>
                                        每提供1个得1分，最多5分。
                                    </td>
                                    <td id="ipScore">3</td>
                                </tr>
                                <tr>
                                    <td>环保节能（1分）</td>
                                    <td>
                                        （1）投标产品中有自己清单范围内属于优先采购的"节能产品"，提供国家确定的认证机构出具的、处于有效期之内的节能产品认证证书复印件，加5分，否则不得分。<br>
                                        （2）投标产品中有自己清单范围内属于优先采购的"环境标志产品"，提供国家确定的认证机构出具的、处于有效期之内的环境标志产品认证证书复印件，加5分，否则不得分。
                                    </td>
                                    <td id="envScore">1</td>
                                </tr>
                                <tr>
                                    <td rowspan="4">技术部分（59分）</td>
                                    <td rowspan="4">技术响应（37分）</td>
                                    <td>
                                        投标人对本项目"一、技术需求、二、服务需求"3个响应情况，全部内容完全响应得满分37分，共118项指标（其中★号7项，●号6项，普通92项）
                                    </td>
                                    <td id="techResponseScore">35.5</td>
                                </tr>
                                <tr>
                                    <td>
                                        （1）"★"代表实质性指标，不满足该指标按无效投标处理。
                                    </td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>
                                        （2）"●"代表重要型指标，每有一项不满足，扣1.5分，共计25.5分
                                    </td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>
                                        （3）"无标记号"则表示一般性指标，每有一项不满足，扣0.092分，共计8.5分
                                    </td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td rowspan="4">技术部分（59分）</td>
                                    <td rowspan="4">服务方案（22分）</td>
                                    <td>
                                        (1) 整体方案设计清晰、表达充分，架构描述、技术方案描述、科学、合理、流程性强，对环境要求分析，项目实施关键节点把握，培训、售后、应急、运维方案调度满足需求，得11分；
                                    </td>
                                    <td id="serviceScore1">9</td>
                                </tr>
                                <tr>
                                    <td>
                                        (2) 整体方案设计基本清晰、表达基本充分，技术描述不够人性化、科学、合理，流程性较强，项目实施关键节点时间节点基本准确，项目进度把握描述基本清晰，得6分；
                                    </td>
                                    <td id="serviceScore2">5</td>
                                </tr>
                                <tr>
                                    <td>
                                        (3) 整体方案设计不不够清晰，表达不够充分，部分描述不够人性化，技术方案不够详尽、科学、合理，流程性不够强，项目实施关键节点时间节点不够清晰，得4分；
                                    </td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>
                                        (4) 没有技术方案，得0分。
                                    </td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>技术部分（59分）</td>
                                    <td>系统迁移方案（11分）</td>
                                    <td>
                                        系统迁移技术方案合理完善，提供高可用技术工具和定制化迁移服务方案，保障全面的数据备份策略，确保高效、安全过渡、具有对比科技指标进行有效评测能力，提供全天候技术客户支持，得11分；<br>
                                        系统迁移技术水平能力一般，满足参数迁移要求，服务高效且安全，客户支持有效，得8分；<br>
                                        技术和服务能力一般，迁移效率低下，安全性一般，客户服务一般，得4分；<br>
                                        无完整方案，不得分。
                                    </td>
                                    <td id="migrationScore">8</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    <div class="mt-4">
                        <h5>专家评分情况</h5>
                        <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>专家</th>
                                    <th>价格标</th>
                                    <th>商务标</th>
                                    <th>技术标</th>
                                    <th>总分</th>
                                </tr>
                            </thead>
                            <tbody id="expertScoreTable">
                                <tr>
                                    <td>1</td>
                                    <td>专家A</td>
                                    <td>28.5</td>
                                    <td>10</td>
                                    <td>55</td>
                                    <td>93.5</td>
                                </tr>
                                <tr>
                                    <td>2</td>
                                    <td>专家B</td>
                                    <td>28.5</td>
                                    <td>9</td>
                                    <td>52</td>
                                    <td>89.5</td>
                                </tr>
                                <tr>
                                    <td>3</td>
                                    <td>专家C</td>
                                    <td>28.5</td>
                                    <td>10</td>
                                    <td>50</td>
                                    <td>88.5</td>
                                </tr>
                                <tr>
                                    <td>4</td>
                                    <td>专家D</td>
                                    <td>28.5</td>
                                    <td>8</td>
                                    <td>53</td>
                                    <td>89.5</td>
                                </tr>
                                <tr>
                                    <td>5</td>
                                    <td>专家E</td>
                                    <td>28.5</td>
                                    <td>9</td>
                                    <td>47</td>
                                    <td>84.5</td>
                                </tr>
                                <tr class="font-weight-bold">
                                    <td colspan="2">平均分</td>
                                    <td>28.5</td>
                                    <td>9.2</td>
                                    <td>51.4</td>
                                    <td>89.1</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    <div class="signature-area mt-4">
                        <div class="signature-box">
                            <div class="signature-line"></div>
                            <div>评审组长签名</div>
                        </div>
                        <div class="signature-box ml-4">
                            <div class="signature-line"></div>
                            <div>日期</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/xlsx@0.16.9/dist/xlsx.full.min.js"></script>
    <style>
        @media print {
            .no-print-modal {
                display: none !important;
            }
            .modal {
                position: absolute;
                left: 0;
                top: 0;
                margin: 0;
                padding: 0;
                overflow: visible !important;
            }
            .modal-dialog {
                width: 100%;
                max-width: 100%;
                margin: 0;
            }
            .modal-content {
                border: none;
            }
            body {
                visibility: hidden;
            }
            #supplierDetailContent {
                visibility: visible;
                position: absolute;
                left: 0;
                top: 0;
            }
            .table {
                width: 100%;
            }
        }
    </style>
    <script>
        // 选中行时显示供应商面板
        function toggleSupplierPanel(id) {
            const panel = document.getElementById('supplierPanel');
            if (panel.style.display === 'none') {
                panel.style.display = 'block';
                
                // 根据ID加载不同项目的供应商数据
                loadSupplierData(id);
                
                // 取消其他行的选中状态
                document.querySelectorAll('tr.selected').forEach(row => {
                    row.classList.remove('selected');
                });
                
                // 选中当前行
                document.querySelector(`tr[data-id="${id}"]`).classList.add('selected');
            } else {
                // 如果点击的是当前选中行，则隐藏面板
                if (document.querySelector(`tr[data-id="${id}"]`).classList.contains('selected')) {
                    panel.style.display = 'none';
                    document.querySelector(`tr[data-id="${id}"]`).classList.remove('selected');
                } else {
                    // 否则切换到新选中的行数据
                    loadSupplierData(id);
                    document.querySelectorAll('tr.selected').forEach(row => {
                        row.classList.remove('selected');
                    });
                    document.querySelector(`tr[data-id="${id}"]`).classList.add('selected');
                }
            }
        }

        // 加载供应商数据
        function loadSupplierData(id) {
            // 这里应该是从后端API获取数据，这里仅做演示
            const projectData = {
                1: {
                    name: "福州市某医院信息化建设项目",
                    code: "PRJ2022-001",
                    date: "2022-01-14",
                    manager: "张三",
                    contact: "13800138000",
                    suppliers: [
                        { id: 1, name: "A公司", score: 89, rank: 1 },
                        { id: 2, name: "B公司", score: 87, rank: 2 },
                        { id: 3, name: "C公司", score: 79, rank: 3 },
                        { id: 4, name: "D公司", score: 74, rank: 4 },
                        { id: 5, name: "E公司", score: 69, rank: 5 }
                    ]
                },
                2: {
                    name: "某市智慧城市建设项目",
                    code: "PRJ2020-045",
                    date: "2020-09-21",
                    manager: "李四",
                    contact: "13911112222",
                    suppliers: [
                        { id: 1, name: "X公司", score: 92, rank: 1 },
                        { id: 2, name: "Y公司", score: 85, rank: 2 },
                        { id: 3, name: "Z公司", score: 78, rank: 3 }
                    ]
                },
                3: {
                    name: "某区智能交通系统项目",
                    code: "PRJ2024-012",
                    date: "2024-02-26",
                    manager: "王五",
                    contact: "13922223333",
                    suppliers: [
                        { id: 1, name: "甲公司", score: 88, rank: 1 },
                        { id: 2, name: "乙公司", score: 82, rank: 2 },
                        { id: 3, name: "丙公司", score: 75, rank: 3 },
                        { id: 4, name: "丁公司", score: 70, rank: 4 }
                    ]
                }
            };

            const data = projectData[id];
            if (data) {
                document.getElementById('projectName').textContent = data.name;
                document.getElementById('projectCode').textContent = data.code;
                document.getElementById('reviewDate').textContent = data.date;
                document.getElementById('projectManager').textContent = data.manager;
                document.getElementById('contactInfo').textContent = data.contact;

                // 更新供应商列表
                const supplierList = document.getElementById('supplierList');
                supplierList.innerHTML = '';
                
                data.suppliers.forEach((supplier, index) => {
                    const row = document.createElement('tr');
                    row.innerHTML = `
                        <td>${index + 1}</td>
                        <td>${supplier.name}</td>
                        <td>${supplier.score}</td>
                        <td>${supplier.rank}</td>
                        <td><button class="btn btn-sm btn-info supplier-detail-btn no-print">查看详情</button></td>
                    `;
                    supplierList.appendChild(row);
                });
            }
        }

        // 打印功能
        function printPage() {
            // 确保供应商面板是可见的
            if (document.getElementById('supplierPanel').style.display === 'none') {
                alert('请先选择一个项目查看供应商评分信息');
                return;
            }
            window.print();
        }

        // 导出Excel功能
        function downloadExcel() {
            // 确保供应商面板是可见的
            if (document.getElementById('supplierPanel').style.display === 'none') {
                alert('请先选择一个项目查看供应商评分信息');
                return;
            }

            // 获取项目信息
            const projectName = document.getElementById('projectName').textContent;
            const reviewDate = document.getElementById('reviewDate').textContent;
            const projectCode = document.getElementById('projectCode').textContent;
            const projectManager = document.getElementById('projectManager').textContent;

            // 创建工作簿
            const wb = XLSX.utils.book_new();
            
            // 项目信息
            const projectInfo = [
                ['项目名称', projectName],
                ['项目编号', projectCode],
                ['评审日期', reviewDate],
                ['项目负责人', projectManager],
                ['', ''],
                ['供应商评分信息', '']
            ];
            
            // 表头
            const headers = ['序号', '供应商名称', '总分', '排名'];
            projectInfo.push(headers);
            
            // 获取供应商数据
            const supplierRows = document.querySelectorAll('#supplierList tr');
            supplierRows.forEach(row => {
                const cells = row.querySelectorAll('td');
                const rowData = [
                    cells[0].textContent,
                    cells[1].textContent,
                    cells[2].textContent,
                    cells[3].textContent
                ];
                projectInfo.push(rowData);
            });
            
            // 创建工作表
            const ws = XLSX.utils.aoa_to_sheet(projectInfo);
            
            // 添加到工作簿
            XLSX.utils.book_append_sheet(wb, ws, '项目评分信息');
            
            // 导出Excel文件
            XLSX.writeFile(wb, `${projectName}-评分信息.xlsx`);
        }

        // 全选功能
        document.getElementById('selectAll').addEventListener('change', function() {
            const checkboxes = document.querySelectorAll('.row-checkbox');
            checkboxes.forEach(checkbox => {
                checkbox.checked = this.checked;
            });
        });

        // 阻止复选框点击事件冒泡，避免触发行点击事件
        document.querySelectorAll('.row-checkbox').forEach(checkbox => {
            checkbox.addEventListener('click', function(e) {
                e.stopPropagation();
            });
        });

        // 查看供应商详情
        $(document).on('click', '.btn-info', function(e) {
            e.stopPropagation();
            
            // 获取当前行的数据
            const row = $(this).closest('tr');
            const projectId = row.data('id');
            const supplierIndex = row.index();
            
            // 打开模态框
            $('#supplierDetailModal').modal('show');
            
            // 加载供应商详情数据
            loadSupplierDetail(projectId, supplierIndex);
        });

        // 修改为区分项目详情按钮和供应商详情按钮
        // 项目详情按钮 - 显示下方供应商面板
        $(document).on('click', '.project-detail-btn', function(e) {
            e.stopPropagation();
            
            // 获取当前行的项目ID
            const row = $(this).closest('tr');
            const projectId = row.data('id');
            
            // 显示供应商面板
            toggleSupplierPanel(projectId);
        });

        // 供应商详情按钮 - 弹出模态框显示专家评分
        $(document).on('click', '.supplier-detail-btn', function(e) {
            e.stopPropagation();
            
            // 获取项目ID和供应商索引
            const projectId = $('#projectCode').text().replace('PRJ', '').split('-')[0];
            const supplierRow = $(this).closest('tr');
            const supplierIndex = supplierRow.index();
            const supplierName = supplierRow.find('td:eq(1)').text();
            
            // 打开模态框
            $('#supplierDetailModal').modal('show');
            
            // 加载供应商详情数据
            loadSupplierDetail(projectId, supplierName);
        });

        // 加载供应商详情数据
        function loadSupplierDetail(projectId, supplierName) {
            // 这里应该是从后端API获取数据，这里仅做演示
            const projectData = {
                1: {
                    name: "福州市某医院信息化建设项目",
                    code: "PRJ2022-001",
                    date: "2022-01-14",
                    manager: "张三",
                    contact: "13800138000",
                    suppliers: {
                        "A公司": { 
                            score: 89, 
                            rank: 1,
                            details: {
                                price: 28.5,
                                case: 4,
                                qualification: 2,
                                ip: 3,
                                env: 1,
                                techResponse: 35.5,
                                service1: 9,
                                service2: 5,
                                migration: 8
                            },
                            experts: [
                                { name: "专家A", price: 28.5, business: 10, tech: 55, total: 93.5 },
                                { name: "专家B", price: 28.5, business: 9, tech: 52, total: 89.5 },
                                { name: "专家C", price: 28.5, business: 10, tech: 50, total: 88.5 },
                                { name: "专家D", price: 28.5, business: 8, tech: 53, total: 89.5 },
                                { name: "专家E", price: 28.5, business: 9, tech: 47, total: 84.5 }
                            ]
                        },
                        "B公司": { 
                            score: 87, 
                            rank: 2,
                            details: {
                                price: 27.2,
                                case: 5,
                                qualification: 2,
                                ip: 4,
                                env: 0,
                                techResponse: 34.8,
                                service1: 8,
                                service2: 5,
                                migration: 7
                            },
                            experts: [
                                { name: "专家A", price: 27.2, business: 11, tech: 49, total: 87.2 },
                                { name: "专家B", price: 27.2, business: 11, tech: 50, total: 88.2 },
                                { name: "专家C", price: 27.2, business: 10, tech: 48, total: 85.2 },
                                { name: "专家D", price: 27.2, business: 11, tech: 51, total: 89.2 },
                                { name: "专家E", price: 27.2, business: 10, tech: 47, total: 84.2 }
                            ]
                        },
                        "C公司": { 
                            score: 79, 
                            rank: 3,
                            details: {
                                price: 26.8,
                                case: 3,
                                qualification: 2,
                                ip: 2,
                                env: 0,
                                techResponse: 32.2,
                                service1: 7,
                                service2: 4,
                                migration: 6
                            },
                            experts: [
                                { name: "专家A", price: 26.8, business: 7, tech: 45, total: 78.8 },
                                { name: "专家B", price: 26.8, business: 7, tech: 46, total: 79.8 },
                                { name: "专家C", price: 26.8, business: 7, tech: 44, total: 77.8 },
                                { name: "专家D", price: 26.8, business: 7, tech: 47, total: 80.8 },
                                { name: "专家E", price: 26.8, business: 7, tech: 43, total: 76.8 }
                            ]
                        },
                        "D公司": { 
                            score: 74, 
                            rank: 4,
                            details: {
                                price: 25.5,
                                case: 2,
                                qualification: 2,
                                ip: 1,
                                env: 0,
                                techResponse: 30.5,
                                service1: 7,
                                service2: 4,
                                migration: 5
                            },
                            experts: [
                                { name: "专家A", price: 25.5, business: 5, tech: 43, total: 73.5 },
                                { name: "专家B", price: 25.5, business: 5, tech: 44, total: 74.5 },
                                { name: "专家C", price: 25.5, business: 5, tech: 42, total: 72.5 },
                                { name: "专家D", price: 25.5, business: 5, tech: 45, total: 75.5 },
                                { name: "专家E", price: 25.5, business: 5, tech: 41, total: 71.5 }
                            ]
                        },
                        "E公司": { 
                            score: 69, 
                            rank: 5,
                            details: {
                                price: 24.0,
                                case: 2,
                                qualification: 1,
                                ip: 1,
                                env: 0,
                                techResponse: 28.0,
                                service1: 6,
                                service2: 4,
                                migration: 5
                            },
                            experts: [
                                { name: "专家A", price: 24.0, business: 4, tech: 41, total: 69.0 },
                                { name: "专家B", price: 24.0, business: 4, tech: 42, total: 70.0 },
                                { name: "专家C", price: 24.0, business: 4, tech: 40, total: 68.0 },
                                { name: "专家D", price: 24.0, business: 4, tech: 43, total: 71.0 },
                                { name: "专家E", price: 24.0, business: 4, tech: 39, total: 67.0 }
                            ]
                        }
                    }
                },
                2: {
                    name: "某市智慧城市建设项目",
                    code: "PRJ2020-045",
                    date: "2020-09-21",
                    manager: "李四",
                    contact: "13911112222",
                    suppliers: {
                        "X公司": { 
                            score: 92, 
                            rank: 1,
                            details: {
                                price: 30.0,
                                case: 5,
                                qualification: 2,
                                ip: 5,
                                env: 1,
                                techResponse: 36.0,
                                service1: 10,
                                service2: 5,
                                migration: 10
                            },
                            experts: [
                                { name: "专家A", price: 30.0, business: 13, tech: 50, total: 93.0 },
                                { name: "专家B", price: 30.0, business: 13, tech: 51, total: 94.0 },
                                { name: "专家C", price: 30.0, business: 13, tech: 49, total: 92.0 },
                                { name: "专家D", price: 30.0, business: 13, tech: 52, total: 95.0 },
                                { name: "专家E", price: 30.0, business: 13, tech: 48, total: 91.0 }
                            ]
                        }
                    }
                }
            };

            const project = projectData[projectId];
            if (project && project.suppliers[supplierName]) {
                const supplier = project.suppliers[supplierName];
                
                // 更新模态框内容
                $('#detailProjectName').text(project.name);
                $('#detailReviewDate').text(project.date);
                $('#detailSupplierName').text(supplierName);
                $('#detailTotalScore').text(supplier.score);
                $('#detailRank').text(supplier.rank);
                
                // 更新评分详情
                $('#priceScore').text(supplier.details.price);
                $('#caseScore').text(supplier.details.case);
                $('#qualificationScore').text(supplier.details.qualification);
                $('#ipScore').text(supplier.details.ip);
                $('#envScore').text(supplier.details.env);
                $('#techResponseScore').text(supplier.details.techResponse);
                $('#serviceScore1').text(supplier.details.service1);
                $('#serviceScore2').text(supplier.details.service2);
                $('#migrationScore').text(supplier.details.migration);
                
                // 更新专家评分表
                const expertTable = $('#expertScoreTable');
                expertTable.html('');
                
                let totalPrice = 0;
                let totalBusiness = 0;
                let totalTech = 0;
                let totalScore = 0;
                
                supplier.experts.forEach((expert, index) => {
                    const row = $('<tr></tr>');
                    row.append(`<td>${index + 1}</td>`);
                    row.append(`<td>${expert.name}</td>`);
                    row.append(`<td>${expert.price}</td>`);
                    row.append(`<td>${expert.business}</td>`);
                    row.append(`<td>${expert.tech}</td>`);
                    row.append(`<td>${expert.total}</td>`);
                    expertTable.append(row);
                    
                    totalPrice += expert.price;
                    totalBusiness += expert.business;
                    totalTech += expert.tech;
                    totalScore += expert.total;
                });
                
                // 添加平均分行
                const avgRow = $('<tr class="font-weight-bold"></tr>');
                avgRow.append('<td colspan="2">平均分</td>');
                avgRow.append(`<td>${(totalPrice / supplier.experts.length).toFixed(1)}</td>`);
                avgRow.append(`<td>${(totalBusiness / supplier.experts.length).toFixed(1)}</td>`);
                avgRow.append(`<td>${(totalTech / supplier.experts.length).toFixed(1)}</td>`);
                avgRow.append(`<td>${(totalScore / supplier.experts.length).toFixed(1)}</td>`);
                expertTable.append(avgRow);
            }
        }

        // 打印模态框内容
        function printModalContent() {
            window.print();
        }

        // 导出详情Excel
        function downloadDetailExcel() {
            // 获取项目和供应商信息
            const projectName = $('#detailProjectName').text();
            const reviewDate = $('#detailReviewDate').text();
            const supplierName = $('#detailSupplierName').text();
            
            // 创建工作簿
            const wb = XLSX.utils.book_new();
            
            // 基本信息
            const basicInfo = [
                ['项目评分详情'],
                [''],
                ['项目名称', projectName],
                ['评审日期', reviewDate],
                ['供应商名称', supplierName],
                ['总分', $('#detailTotalScore').text()],
                ['排名', $('#detailRank').text()],
                ['']
            ];
            
            // 评分明细
            basicInfo.push(['评分明细']);
            basicInfo.push(['评分因素', '评分内容', '分值']);
            basicInfo.push(['报价（30分）', '报价', $('#priceScore').text()]);
            basicInfo.push(['商务部分（11分）', '类似项目案例', $('#caseScore').text()]);
            basicInfo.push(['', '投标人资质', $('#qualificationScore').text()]);
            basicInfo.push(['', '知识产权', $('#ipScore').text()]);
            basicInfo.push(['', '环保节能', $('#envScore').text()]);
            basicInfo.push(['技术部分（59分）', '技术响应', $('#techResponseScore').text()]);
            basicInfo.push(['', '服务方案1', $('#serviceScore1').text()]);
            basicInfo.push(['', '服务方案2', $('#serviceScore2').text()]);
            basicInfo.push(['', '系统迁移方案', $('#migrationScore').text()]);
            basicInfo.push(['']);
            
            // 专家评分
            basicInfo.push(['专家评分情况']);
            basicInfo.push(['序号', '专家', '价格标', '商务标', '技术标', '总分']);
            
            const expertRows = $('#expertScoreTable tr');
            expertRows.each(function(index) {
                if (index < expertRows.length - 1) { // 不包括平均分行
                    const cells = $(this).find('td');
                    basicInfo.push([
                        cells.eq(0).text(),
                        cells.eq(1).text(),
                        cells.eq(2).text(),
                        cells.eq(3).text(),
                        cells.eq(4).text(),
                        cells.eq(5).text()
                    ]);
                }
            });
            
            // 添加平均分
            const avgCells = $(expertRows[expertRows.length - 1]).find('td');
            basicInfo.push([
                '平均',
                '',
                avgCells.eq(2).text(),
                avgCells.eq(3).text(),
                avgCells.eq(4).text(),
                avgCells.eq(5).text()
            ]);
            
            // 创建工作表
            const ws = XLSX.utils.aoa_to_sheet(basicInfo);
            
            // 添加到工作簿
            XLSX.utils.book_append_sheet(wb, ws, '供应商评分详情');
            
            // 导出Excel文件
            XLSX.writeFile(wb, `${projectName}-${supplierName}-评分详情.xlsx`);
        }
    </script>
</body>
</html>
